package com.ingenieria;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;

public class Splash extends Activity {

    SharedPreferences preferences;
    SharedPreferences.Editor editor;
    Category category;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);

	    preferences = getSharedPreferences("categorias", Context.MODE_PRIVATE);
	    editor = preferences.edit();
		editor.commit();
        
        Thread t = new Thread() {
            public void run() {
                try {
                    Thread.sleep(1500);
                    if(preferences.getInt("size", 0) != 0){
                        Intent intent = new Intent();
                    		Log.i("Categorias guardadas", "categorias guardadas");
                            intent.setClass(Splash.this, Ingenieria.class);
                            startActivity(intent);
                            finish();
                    }else{
                        Intent intent = new Intent();
//                    		Log.i("Ninguna categoria guardada", "Ninguna categoria guardad");
                          intent.setClass(Splash.this, Categories.class);
                          startActivity(intent);
                          finish();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        t.start();
	}
}
